package com.jinniulive.platform.adapter;

import android.content.Context;
import android.support.v4.view.PagerAdapter;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import java.util.List;

/**
 * Created by Administrator on 2016/11/30.
 */

public class GuidePageViewPager extends PagerAdapter {
    private Context mContext;
    private List<ImageView> mList;

    public GuidePageViewPager(Context context, List<ImageView> list) {
        mContext = context;
        mList = list;
    }

    @Override
    public int getCount() {
        return mList == null?0:mList.size();
    }

    @Override
    public View instantiateItem(ViewGroup container, int position) {
        View ret =null;
        ret = mList.get(position);
        container.addView(ret);
        return  ret;
    }


    @Override
    public boolean isViewFromObject(View view, Object object) {
        return view == object;
    }

    @Override
    public void destroyItem(ViewGroup container, int position, Object object) {
        if ( object instanceof View){
            View view = (View)object;
            container.removeView(view);
        }
    }
}
